﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection;
using WinnerCMS.BLL;
using WinnerCMS.Common;
using WinnerCMS.Model;

#endregion

namespace WinnerCMS.WebUI.Admin.Admin
{
    public partial class ChangePSW : Page
    {
        private readonly AdminManage _myBll = PolicyInjection.Create<AdminManage>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(IsPostBack))
            {
                this.btnChangePSW.Attributes.Add("onclick", "return CheckPSW1();");
                this.lblUserName.Text = Request["UserName"];

                if (Request["UserName"] != UserManage.Current.UserName)
                {
                    MsgBox.Message("你只能修改自己的密码！", this);
                }
            }
        }

        protected void btnChangePSW_Click(object sender, EventArgs e)
        {
            var model = new User
            {
                UserName = Request["UserName"]
                ,
                PassWord = this.txtOldPSW.Text
            };

            var resu = this._myBll.ChangPSW(model, this.txtNew_PSW1.Text);
            if (string.IsNullOrEmpty(resu.Errors))
            {
                this.lblMessage.Text = "密码修改成功！";
            }
            else
                this.lblMessage.Text = resu.Errors;
        }
    }
}